
all:system
	objcopy -I elf64-x86-64 -S -R ".eh_frame" -R ".comment" -O binary system kernel.bin

system:head.o main.o printk.o trap.o entry.o
	ld -b elf64-x86-64 -z muldefs -o system head.o main.o printk.o trap.o entry.o -T Kernel.lds

main.o:main.c lib.h
	gcc -static  -mcmodel=large -fno-builtin -m64 -c main.c  -fno-stack-protector

printk.o:printk.c lib.h
	gcc -static  -mcmodel=large -fno-builtin -m64 -c printk.c -fno-stack-protector

trap.o:trap.c
	gcc -static  -mcmodel=large -fno-builtin -m64 -c trap.c -fno-stack-protector

head.o:head.S
	gcc -E head.S > head.s
	as --64 -o head.o head.s

entry.o:entry.S
	gcc -E entry.S > entry.s
	as --64 -o entry.o entry.s

clean:
	rm -fr *.o *.s *.bin system